package oa.controller;

import oa.service.HBaseService;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.Iterator;
import java.util.List;
import java.util.Map;

@Controller
public class TestController {

    @RequestMapping("/easyui")
    //@ResponseBody
    public String test() {
        System.out.println("easyui");
        return "easyui";
    }

    @Resource
    private HBaseService hBaseService;

    @RequestMapping("hbase")
    @ResponseBody
    public String hbase() {
        List<Map<String, Object>> music = hBaseService.find("music", null, null);
        System.out.println("共" + music.size() + "条数据");
        Iterator<Map<String, Object>> iterator = music.iterator();
        while(iterator.hasNext()) {
            Map<String, Object> m = iterator.next();
            System.out.println(m.get("row") + "：" + m.get("info_name") + "：" + m.get("info_singer"));
        }
        return hBaseService.get("music", "1_song1_2016-1-11", "info", "name");
    }
}
